Skip to content

guardrail: prohibit the destructive-prepend one-liner (P0) + mandatory wc -l post-check - #1083

Merged
AdaWorldAPI merged 1 commit into
mainfrom
claude/prohibit-destructive-prepend
Aug 30, 2026
Merged

guardrail: prohibit the destructive-prepend one-liner (P0) + mandatory wc -l post-check#1083
AdaWorldAPI merged 1 commit into
mainfrom
claude/prohibit-destructive-prepend

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

What

Makes the pattern that destroyed PR_ARC_INVENTORY.md in #1081 (restored in #1082) canonically prohibited, not just documented as a trap:

  1. CLAUDE.md § In-Session Orchestration Discipline — new P0 rule:

    open(p, "w").write(entry + open(p).read())   # NEVER — truncates before it reads

    open(p, "w") truncates BEFORE the argument's open(p).read() runs; the read-back is empty and the file's history is gone. Prohibited in every form — any expression, statement, or shell pipeline that opens a file for writing while it still needs to read that same file (sort f > f is the same defect). Prepend = read into a variable → compose in memory → write, or use the Edit tool (read-anchored by construction). Mandatory post-check after every board/ledger write: wc -l — an append-only file that got SHORTER is always a defect.

  2. EPIPHANIES.md — prepends E-DESTRUCTIVE-PREPEND-TRUNCATES-BEFORE-READ-1 (FINDING + PROHIBITION, operator-directed), cross-referencing census trap 10 and restore PR board: restore PR_ARC_INVENTORY.md (5876 lines destroyed by #1081's destructive prepend) #1082, and sharpening the existing "Read before Write, always" P0: it applies WITHIN a single expression's evaluation order, not just across tool calls.

Post-check (the rule, applied to this PR's own writes)

  • EPIPHANIES.md: 23279 → 23322 lines (longer, entry prepended via Edit)
  • CLAUDE.md: grew by the new rule block
  • No other file touched

Generated by Claude Code

CLAUDE.md In-Session Orchestration Discipline gains a P0 rule banning
open(p, 'w').write(entry + open(p).read()) and every same-file
truncate-while-reading shape (incl. 'sort f > f'), with the mandatory
wc -l post-check after every ledger write. EPIPHANIES.md gains
E-DESTRUCTIVE-PREPEND-TRUNCATES-BEFORE-READ-1 (prepended, append-only
discipline observed: read-into-variable was NOT used here — the Edit
tool was, which is read-anchored by construction).

Provenance: the pattern destroyed 5876 lines of PR_ARC_INVENTORY.md in
the #1081 hygiene commit; restored in #1082 (82679c3); census trap 10
already banked. This PR makes the prohibition canonical.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KCGhDYoQBXs3poaR7sFuqp
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@AdaWorldAPI
AdaWorldAPI merged commit 352005d into main Aug 30, 2026
@cursor

cursor Bot commented Aug 30, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_48fc72bb-f846-4763-a32c-93b1bcc4312f)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants